<?php 

$sql = "SELECT
                     p.cover,
					 p.video,
                     d.title,
					 d.description,
					 d.meta_key,
			 		 d.meta_description
                FROM
                    products AS p,
                    product_description AS d
                WHERE
                	p.product_id = d.product_id
                    
                    AND
                    
                    d.lang_id = '".$_SESSION['lang_id']."'
                    
                    AND
                    
					p.published
					
					AND p.product_id = '".$sef_url."'
                    
                  ";

$result = query($sql);
$row = mysql_fetch_object($result);

head(sth($row->title),sth($row->meta_description),'','products');



/*$sql_c = "SELECT
                     c.sef_url AS class,
					 d.Name,
                     s.sef_url
                FROM
                    category AS c,
                    category_description AS d,
					sef_url AS s
					
                WHERE
                	c.category_id = d.category_id
                    
                    AND
                    
                    d.lang_id = '".$_SESSION['lang_id']."'
                    
                    AND
                    
					c.published
					
					AND c.category_id = (SELECT category_id FROM product_to_category WHERE product_id = '".$sef_url."' LIMIT 1)
					
					AND  s.tamplate = 'category'
					
					AND s.query = c.category_id
					
					AND s.lang_id = '".$_SESSION['lang_id']."'
                    
                  ";

$result_c = query($sql_c);
$rcat = mysql_fetch_object($result_c);*/


?>


<section id="product-container">
           <header>
               <h5><a style="color:#FFF;" onclick="window.history.back(); return false;" href="#">&larr;</a> <?=sth($row->title)?></h5>
               <h2 id="product-name"><?=sth($row->meta_description)?></h2>
               
           </header>
           <div id="product-description" class="cf">
               <div id="product-image">
                   <img src="<?=HTTPS_BASE?>product_images/big/<?=$row->cover?>" alt="">
               </div>
               <div id="product-info">
                   <?=stripslashes($row->description)?>
               </div>
           </div>
           <footer>
             
			

           </footer>
       </section>
       
       <?php
       
	   if($_SESSION['category_id'] > 0){
		   
		   $sql = "SELECT
            c.cover,
		    d.title,
			d.meta_description,
            s.sef_url


        FROM
            products AS c,
            product_description AS d,
            product_to_category AS p2c,
            sef_url AS s
        WHERE
            p2c.product_id =  c.product_id
            AND 
            p2c.category_id = '".$_SESSION['category_id']."'
            AND 
            s.query = c.product_id

            AND

            c.product_id = d.product_id
			
			AND
			
			c.product_id != '".$sef_url."'

            AND
            s.tamplate='product'

            AND

            d.lang_id = '".$_SESSION['lang_id']."'

            AND

            s.lang_id = '".$_SESSION['lang_id']."'

            AND c.published


            ORDER BY  c.order_number DESC
			
			LIMIT 4

          ";
        $result = query($sql);
		
		if($result){
	   ?>
       
       <div id="related-products">
           <h4>Вижте също:</h4>
       </div>
             <div id="product-grid">
            <ul>
            <?php
              while ($row = mysql_fetch_object($result)) {


		?>
                <li class="product-item">
                            <a href="<?=HTTPS_BASE.$row->sef_url?>">
                                <h5><?=$row->title?></h5>
                                <div class="product-item-name"><?=$row->meta_description?></div>
                                <div class="product-item-image">
                                     <img src="<?=HTTPS_BASE?>product_images/big/<?=$row->cover?>" alt="<?=$row->title?>" title="<?=$row->title?>"/>
                                </div>
                            </a>
                </li>
        
        
        <?php }?>  
            </ul>
        </div> <!--#product-grid-->
        
       <?php 
	  	 //$_SESSION['category_id'] = '';
		}
	   } 
	   
	   ?>

<?php
foot();
?>